package com.jetpack_sunflower.viewmodels

import androidx.lifecycle.LiveData
import androidx.lifecycle.Transformations
import androidx.lifecycle.ViewModel
import com.jetpack_sunflower.data.GardenPlantingRepository
import com.jetpack_sunflower.data.PlantAndGardenPlantings

class GardenPlantingListViewModel internal constructor(private val gardenPlantingRepository: GardenPlantingRepository) : ViewModel() {
    val gardenPlantings = gardenPlantingRepository.getGardenPlantings()

    val plantAndGardenPlantings: LiveData<List<PlantAndGardenPlantings>> =
            Transformations.map(gardenPlantingRepository.getPlantAndGardenPlantings()) {
                it.filter { plantings ->
                    plantings.gardenPlantings.isNotEmpty()
                }
            }
}

/*val gardenPlantings = gardenPlantingRepository.getGardenPlantings()

    val plantAndGardenPlantings: LiveData<List<PlantAndGardenPlantings>> =
            Transformations.map(gardenPlantingRepository.getPlantAndGardenPlantings()) { plantings ->
                plantings.filter { it.gardenPlantings.isNotEmpty() }
            }*/